<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<c:set value="${requestScope.response.data.list }" var="list"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>购物车列表 - 美妆产品销售系统</title>
		<%@ include file="/common/include/head_title.jsp"%>
	</head>
	<body>
		<jsp:include page="/IndexHeadServlet">
			<jsp:param value="header" name="method"/>
		</jsp:include>
		<section class="page-content-wrapper login-area ptb-100">
			<div class="container">
				<div class="row">
				   <div class="col-md-12 col-sm-12 col-xs-12">
						<form action="#">				
							<div class="table-content table-responsive">
								<table>
									<thead>
										<tr>
											<th class="product-thumbnail">序号</th>
											<th class="product-thumbnail">图片</th>
											<th class="product-name">名称</th>
											<th class="product-price">价格</th>
											<th class="product-quantity">数量</th>
											<th class="product-subtotal">总价格</th>
											<th class="product-remove">操作</th>
										</tr>
									</thead>
									<tbody>
										<c:set value="0" var="totalMoney"/>
										<c:set value="0" var="totalNum"/>
										<c:forEach items="${list }" var="listTemp" varStatus="stat">
											<tr>
												<td class="product-thumbnail">${stat.count }</td>
												<td class="product-thumbnail">
													<a href="${rootPath }/IndexHeadServlet?method=productInfo&id=${listTemp.prodId }" target="_blank" title="${listTemp.product.name }">
														<c:choose>
															<c:when test="${listTemp.product.pic != null && listTemp.product.pic != '' }">
																<a href="${websiteFileUrl}${listTemp.product.pic }" target="_blank">
																	<img alt="" src="${websiteFileUrl}${listTemp.product.pic }" width="130" height="130">
																</a>
															</c:when>
															<c:otherwise>
																<img alt="" src="${rootPath }/img/no_pic.png" width="130" height="130">
															</c:otherwise>
														</c:choose>
													</a>
												</td>
												<td class="product-name">
													<a href="${rootPath }/IndexHeadServlet?method=productInfo&id=${listTemp.prodId }" target="_blank" title="${listTemp.product.name }">
														${fn:substring(listTemp.product.name,0,subStrLen) }
													</a>
												</td>
												<td class="product-price"><span class="amount">Y${listTemp.product.price }</span></td>
												<td class="product-quantity">${listTemp.num}</td>
												<td class="product-subtotal">${listTemp.product.price * listTemp.num }</td>
												<td class="product-remove">
													<a href="${rootPath }/head/UsersHeadServlet?method=cartDelete&id=${listTemp.id }" onclick="return confirm('确认删除吗?')">
														<i class="fa fa-times"></i>
													</a>
												</td>
											</tr>
											<c:set value="${totalMoney + listTemp.product.price * listTemp.num }" var="totalMoney"/>
											<c:set value="${totalNum + listTemp.num }" var="totalNum"/>
										</c:forEach>
									</tbody>
								</table>
							</div>
							<div class="row">
								<div class="col-md-9 col-sm-7 col-xs-12">
									<div class="buttons-cart">
										<!-- <input type="submit" value="Update Cart"> -->
										<a href="${rootPath }/IndexHeadServlet?method=productList">继续购物</a>
									</div>
									<!-- <div class="coupon">
										<h3>Coupon</h3>
										<p>Enter your coupon code if you have one.</p>
										<input type="text" placeholder="Coupon code">
										<input type="submit" value="Apply Coupon">
									</div> -->
								</div>
								<div class="col-md-3 col-sm-5 col-xs-12">
									<div class="cart_totals">
										<h2>购物车总计:Y</h2>
										<table>
											<tbody>
												<tr class="cart-subtotal">
													<th>总件数</th>
													<td><span class="amount">${totalNum }</span></td>
												</tr>
												<tr class="order-total">
													<th>总金额</th>
													<td>
														<strong><span class="amount">Y${totalMoney}</span></strong>
													</td>
												</tr>											
											</tbody>
										</table>
										<div class="wc-proceed-to-checkout">
											<a href="${rootPath }/head/OrdersHeadServlet?method=ordersInsert">去结算</a>
										</div>
									</div>
								</div>
							</div>
						</form>	
					</div>
				</div>
			</div>
		</section>
		<%@ include file="/common/include/head_footer.jsp"%>
	</body>
</html>